Skip to content

Conversation

@exxocism
Copy link

@exxocism exxocism commented Dec 22, 2024

Description

  • The size of localStorage typically ranges from 2 MB to 10 MB, depending on the browser.
    • This capacity can be quickly exhausted under certain conditions (MDN, GeeksForGeeks)
  • This pull request introduces gzip compression for localStorage by intercepting the storage methods, effectively increasing storage capacity by up to 4 to 5 times.
  • The feature is migratable from uncompressed to compressed storage but not vice versa.
  • It can be disabled using the useCompression switch.
  • Can easily be extended to brotli or other compression method

Major changes

  • Adds pako library for gzip compression: 03a44d8
  • gzip interception to the web ui: b3c5268
  • Pack gz file: 94e7d24

Test env

  • Check the values in the chrome console
  • Check if it migrates smoothly from uncompressed to compressed

TODO

  • Pre/Post merge step: none

@ngxson
Copy link
Collaborator

ngxson commented Dec 22, 2024

IMO this feature is not really needed, because compressing localStorage can make it tricky to debug, while only provide at maximum 5x storage, not scalable.

The more scalable would be to migrate to IndexedDB, which provide at minimum 50MB of storage according some sources on internet (although usually there is no hard limit). There are also many libraries that provide easier-to-use interface.

I would appreciate if you can write an interface for IndexedDB. The compressed localStorage is not a valid solution atm, we can only keep it as a demo if you want to continue.

@exxocism
Copy link
Author

Thanks for the opinion. I agree that migrating to IndexedDB is a good idea, and I’ll explore ways to implement it with minimal changes.
Perhaps we can turn off the useCompression switch and allow some users to make good use of it in the meantime.

@ngxson
Copy link
Collaborator

ngxson commented Dec 22, 2024

We can keep this PR as a demo, but I don't think we can merge it to master, given that IndexedDB is preferred way to go.

@ngxson ngxson added the demo Demonstrate some concept or idea, not intended to be merged label Dec 22, 2024
@exxocism exxocism closed this Jan 19, 2025
@exxocism exxocism deleted the feature/apply_gzip_compression_to_web_ui branch January 19, 2025 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

demo Demonstrate some concept or idea, not intended to be merged examples server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants